package com.jion.testcenter.service;

import com.jion.testcenter.Entity.ConfEntity;
import com.jion.testcenter.mapper.InterfaceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApiServiceImpl implements ApiService {
    /****************环境配置*************************/
    @Autowired
    private  InterfaceMapper interfaceMapper;
    @Override
    public  int EditEnvService(ConfEntity confEntity){
        if (Integer.valueOf(confEntity.getApiType()) == 1){
            int result = interfaceMapper.insertEnv(confEntity);
            return  result;
        }
        else {
            int result = interfaceMapper.updateEnv(confEntity);
            return result;
        }
    }
    @Override
    public  List<ConfEntity> SelectEnvService(){
        List<ConfEntity> confEntity = interfaceMapper.selectEnv();
        return  confEntity;
    }
    @Override
    public int DelectEnv(String id){
        int result = interfaceMapper.delectEnv(id);
        return result;
    }
    @Override
    public ConfEntity SelectOneEnv(String id){
        return interfaceMapper.selectOneEnv( id);
    }
    /*******************************mysql配置***********************************/
    @Override
    public  int EidtMysqlConf(ConfEntity confEntity){
        if (Integer.valueOf(confEntity.getApiType()) == 1){
            int result = interfaceMapper.insertMysqlConf(confEntity);
            return  result;
        }
        else {
            int result = interfaceMapper.updateMysqlConf(confEntity);
            return result;
        }
    }
    @Override
    public  List<ConfEntity> SelectMysqlConf(){
        List<ConfEntity> confEntity = interfaceMapper.selectMysqlConf();
        return  confEntity;
    }
    @Override
    public int DelectMysqlConf(String id){
        int result = interfaceMapper.delectMysqlConf(id);
        return result;
    }
    @Override
    public ConfEntity SelectOneMysqlConf(String id){
        return interfaceMapper.selectOneMysqlConf( id);
    }
}
